using System.Reflection;
using System;
using System.Diagnostics;
using raycaster;
namespace OB
{
  public interface ITestToolkit
  {
    void AssertEqual(float expected, float result);
    void Assert(bool expression);
  }

  public class TestRunner
  {
    private class TestToolkit : ITestToolkit
    {
      #region ITestToolkit Members

      public void AssertEqual(float expected, float result)
      {
        Debug.Assert(Calc.AlmostEqual(expected, result));
      }

      public void Assert(bool expression)
      {
        Debug.Assert(expression);
      }

      #endregion
    }

    public void RunTests()
    {
      Assembly asm = Assembly.GetExecutingAssembly();
      ITestToolkit toolkit = new TestToolkit();
      foreach (Type type in asm.GetTypes())
      {
        Type[] paramTypes = new Type[1];
        paramTypes[0] = typeof(ITestToolkit);
        try
        {
          MethodInfo mi = type.GetMethod("SelfTest", paramTypes);
          mi.Invoke(null, new object[] { toolkit });
        }
        catch
        {
        }
      }
    }
  }
}